#pragma  once
#include<memory>
#include"FileLog.h"
#include"Singleton.h"
#include<mutex>
#include<unordered_map>

namespace tmms{
    namespace base{
        using FileLogPtr = std::shared_ptr<FileLog>;
        class FileMgr:public NonCopyable{
        public:
            FileMgr() = default;
            ~FileMgr() = default;

            void OnCheck();
            FileLogPtr GetFIleLog(const std::string& file_name);
            void RemoveFileLog(const FileLogPtr& log);
            void RotateDays(const FileLogPtr& file);
            void RotateHour(const FileLogPtr& file);
            void Rotateminute(const FileLogPtr& file);
        private:
            std::unordered_map<std::string,FileLogPtr> logs_;
            std::mutex mtx_;
            int last_day_{-1};
            int last_hour_{-1};
            int last_year_{-1};
            int last_month_{-1};
            int last_minute_{-1};
        };
        
    }
}


#define kFileMgr tmms::base::Singleton<tmms::base::FileMgr>::Instance()